<?php


namespace App\Admin\Controllers\Export;

use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;

/**
 * Created By FreeAbrams
 * Date: 2020/11/27
 */
class Controller
{
	public function requestReturnTimeBetween(Request $request)
	{
		$validate = Validator::make($request->all(), [
        	'dateTime' => 'numeric'
        ]);
        if($validate->failed()){
            return false;
        }

        if($request->get('dateTime')) {
    	    $timeStart = Carbon::createFromFormat('Y', $request->get('dateTime'));
	        $timeEnd = Carbon::createFromFormat('Y', $request->get('dateTime'));
	        // $timeStart = new Carbon($request->get('dateTime'));
	        // $timeEnd = new Carbon($request->get('dateTime'));
	        $timeBetween = [$timeStart->startOfYear(), $timeEnd->endOfYear()];

	    }else {
    		$timeStart = new Carbon();
	        $timeEnd = new Carbon();
	        $timeBetween = [$timeStart->startOfYear(), $timeEnd->endOfYear()];
	    }

        return $timeBetween;
	}
}